package com.daryl.jcu_project1_creditscoreform;

import android.os.Bundle;
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class Credit_score_form extends Activity {
	
	/**
	 * @uml.property  name="mLayout"
	 * @uml.associationEnd  
	 */
	private LinearLayout mLayout;
	/**
	 * @uml.property  name="mEditText"
	 * @uml.associationEnd  
	 */
	private EditText mEditText;
	/**
	 * @uml.property  name="mTextViewEntries"
	 * @uml.associationEnd  
	 */
	private TextView mTextViewEntries;
	/**
	 * @uml.property  name="mButton"
	 * @uml.associationEnd  
	 */
	private Button mButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_credit_score_form);
        mLayout = (LinearLayout) findViewById(R.id.secALayout);
        mButton = (Button) findViewById(R.id.addEntriesMoreBtn);
        mTextViewEntries = (TextView) findViewById(R.id.tvEntries);
        mButton.setOnClickListener(onClick());
        mEditText = (EditText) findViewById(R.id.etFacilityType);
        EditText editText = new EditText(this);
        editText.setText("New Text");
        
    }
    
    private OnClickListener onClick() {
        return new OnClickListener() {

            
            public void onClick(View v) {
                mLayout.addView(createNewEditText(mEditText.getText().toString()));
            }
        };
    }
    
    private EditText createNewEditText(String text) {
        final LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        final EditText editText = new EditText(this);
        editText.setLayoutParams(lparams);
        editText.setText("New text: " + text);
        return editText;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_credit_score_form, menu);
        return true;
    }
}
